import {
  request,
  requestPay,
  validator
} from '../../utils/requestUtils';

import { userBehavior } from '../../behaviors/userBehavior'



Page({
  behaviors: [userBehavior],
  data: {
    options: '',
    minHour: new Date().getHours,
    show: false, // 期望送达日期弹框
    deliveryTimeshow: false,// 期望送达时间点
    minDate: new Date().getTime(),
    currentDate: new Date().getTime(),
    form: {
      customerName: '',
      contact: '',
      payableAmount: '0',
      deliveryDate: '',//送达日期
      deliveryStr: '',//送达时间点
      remark: '',
      addrId: '',//地址id
      lines: [],//行信息
    },
    addr: {
      id: '',
    }
  },
  onShow() {
      this.getOrderById(this.options.id)
  },
  onLoad(options) {
    console.log('options2', JSON.parse(JSON.stringify(options)))
  },



  //获取退货单信息
  async getOrderById(id) {
    const result = await request({
      url: `/merchant/merchant_return_order/${id}`,
      method: "GET"
    })
    if (result.data.code == 200) {
      this.setData({
        form: result.data.data
      })
      if (result.data.data.customerReturnOrder.fileIds) {
        this.selectComponent('#listUploader').initListHandler(result.data.data.customerReturnOrder.fileIds.split(',').map(v => {
          return {
            url: v
          }
        }))
      }
    }
  },
  auditShow(){
    this.selectComponent('#audit').showhandler(this.data.form)
  }
})
